﻿<?php 
$v_url = "/record/handle/index.php?modal_dialog_mode=1" . "&hdn_record_work_id=" . $v_record_work_id . "&fuseaction=DISPLAY_NOTIFY" ;
$v_recordtype_filter =$_SESSION['onegate_current_recordtype'];
if(isset($_REQUEST['hdn_recordtype_filter'])){
	$v_recordtype_filter = $_REQUEST['hdn_recordtype_filter'];
}
$v_record_work_id = intval($_REQUEST['hdn_item_id']);
$v_record_id = 0;

if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = intval($_REQUEST['hdn_record_id']);
}
$v_arrs_record_id=explode(",",$v_request_id_record);
//ID nguoi thuc hien cong viec
$v_worker_id = _get_item_attr_by_id($_SESSION['arr_all_staff'],$_SESSION['staff_id'],'id');
$v_worktype=$_REQUEST['hdn_work'];
$v_date= _ddmmyyyy_to_yyyymmdd($_REQUEST['txt_date']);
$v_result =  _replace_bad_char($_REQUEST['txt_result']);
$v_file_id = 0;	

$v_limit_row = _CONST_NUMBER_OF_ROW_PER_LIST;
if(isset($_REQUEST['hdn_record_number_page'])){
	$v_limit_row = $_REQUEST['hdn_record_number_page'];
}

$v_page = 1;
if(isset($_REQUEST['hdn_page'])){
	$v_page = $_REQUEST['hdn_page'];
}
//echo "v_limit_row=".$v_limit_row; exit;
//CSDL SQL
if(_is_sqlserver()){
	$v_result_id = _save_text_to_database('T_TEMP_FILE', 'C_TEXT', $v_result);
	
	$v_status_refuse = 0;
	/*
	$sql = "Exec Onegate_RecordWorkSystemUpdate_Vunh " ;
	$sql = $sql . "'" . $v_request_id_record . "'";
	$sql = $sql . "," . $v_worker_id;
	$sql = $sql . ",'TRINH_LD_PHONG_LAN_DAU,".$v_radio_leader."'";
	$sql = $sql . ",'" . $v_date . "'" ;
	$sql = $sql . "," . $_ISA_AUTOMATIC_UPDATE_WORK_LIST;
	$sql = $sql . ",'" . $v_reason . "'" ;
	$sql = $sql . "," . $v_status_refuse;
	//echo $sql .'<br>'; //exit;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	*/
	for($i=0; $i<sizeof($v_arrs_record_id); $i++){
		//echo $v_arrs_record_id[$i]."<br/>";
		$sql = "Exec Onegate_RecordWorkUpdate ";
		$sql = $sql . $v_record_work_id;
		$sql = $sql . "," . $v_arrs_record_id[$i];
		$sql = $sql . "," . $v_worker_id;//ID nguoi thuc hien cong viec
		$sql = $sql . ",'" . $v_worktype . "'";
		$sql = $sql . ",'" . $v_date."'";
		$sql = $sql . "," . $v_result_id ;
		$sql = $sql . "," . $v_file_id;
		$sql = $sql . ",'" ."Ox"."'";
		$sql = $sql . "," . _CONST_STATUS_UPDATE_DATE ;
		$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
		$rs = $ado_conn->GetRow($sql); 
		$v_error = _replace_bad_char(trim($rs['RET_ERROR']));

		$sql2="	update 	T_ONEGATE_RECORD 
				set 	C_CURRENT_STATUS='DANG_THU_LY',FK_HANDLE_LEADER_FIRST_TIME=".$v_radio_leader;
		$sql2=$sql2." where 	pk_record=".$v_arrs_record_id[$i];
		$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
		$rs = $ado_conn->GetRow($sql2); 
		$v_error = _replace_bad_char(trim($rs['RET_ERROR']));				
		//echo $sql2; exit;
	}
	
}

if (!is_null($v_error) and $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
		//alert("vo day.....1");
			window.location = "<?php echo $v_url; ?>";
		}else{
			//alert("vo day.....2");
			window.history.back();
		}	
	</script><?php
	exit;
}
sleep(0);
?>
<form action="index.php" method="post" name="f_back">
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_HANDLING_RECORD">
	<input type="hidden" name="hdn_record_id"  value="<?php echo $v_record_id; ?>">
	<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $hdn_recordtype_filter;?>">
	<input type="hidden" name="hdn_item_id" value="<?php echo $v_record_work_id;?>">
	<!-- Leav_17102008-->
	<input type="hidden" name="hdn_page" value="<?php echo $v_page;?>">
	<input type="hidden" name="hdn_record_number_page" value="<?php echo $v_limit_row;?>">
	<!-- Leav_17102008_end-->
</form>
<Script language="javascript">
	document.forms(0).submit();
</Script>
